# -*- coding: utf-8 -*-
# File : server.py.py
# Author: taoyahui
# Date : 2022/5/25

from flask import Flask, render_template, config

app = Flask(__name__)
app.config.from_object(config)


# 这里就是使用jinja的模板参数实现数据动态传递
@app.route('/')
def index():
    return render_template('index.html', name='mark', age=18)


@app.route('/index02')
def index02():
    return render_template('index02.html', context_dict={'name': '张三', 'age': 18, 'gender': "男"})


@app.route('/index03')
def index03():
    context_dict = {"name": "mark",
                    "age": "mark",
                    "gender": "girl",
                    "other_info": {"tel": 1365,
                                   "qq": 565656}}
    return render_template('index03.html', **context_dict)


@app.route('/index04')
def index04():
    return render_template('index04.html', gender='femail', age=16)


@app.route('/index05')
def index05():
    context_dict = {
        'countrys': [
            "1-china",
            "2-America",
            "3-French"
        ]
    }
    return render_template('index05.html', **context_dict)

@app.route("/database/add")
def data_add():
    """
    实现数据库对应表的增加(Insert into ...)
    :return:
    """
    return "这是一个数据库添加的功能"

@app.route('/database/show')
def data_show():
    """
    实现数据库对应表(student)表的显示(select * from student)
    :return:
    """
    pass


if __name__ == '__main__':
    app.run(port=5001)
